﻿Public Class LignesConsultations

    Public Property TypeActe() As String
        Get
            If Me.EntityState <> Data.EntityState.Added Then
                Me.BaremesReference.Load()
            End If
            Return Me.Baremes.TypeActe
        End Get
        Set(ByVal value As String)
            Me.Baremes.TypeActe = value
        End Set
    End Property

    Public Property libelleActe() As String
        Get
            If Me.EntityState <> Data.EntityState.Added Then
                Me.BaremesReference.Load()
            End If
            Return Me.Baremes.Libelle
        End Get
        Set(ByVal value As String)
            Me.Baremes.Libelle = value
        End Set
    End Property

    Public ReadOnly Property prixMini() As Double
        Get
            Me.BaremesReference.Load()
            Return Me.Baremes.TarifMini
        End Get
    End Property

    Public ReadOnly Property prixMaxi() As Double
        Get
            Me.BaremesReference.Load()
            Return Me.Baremes.TarifMaxi
        End Get
    End Property

    Public ReadOnly Property prixFixe() As Double
        Get
            Me.BaremesReference.Load()
            Return Me.Baremes.TarifFixe
        End Get
    End Property

    Public ReadOnly Property Animal() As Animaux
        Get
            Me.ConsultationsReference.Load()
            Me.Consultations.AnimauxReference.Load()
            Return Me.Consultations.Animaux
        End Get
    End Property

    Public ReadOnly Property Client() As Clients
        Get
            Me.Animal.ClientsReference.Load()
            Return Me.Animal.Clients
        End Get
    End Property

    Public ReadOnly Property Vaccin() As Vaccins
        Get
            Vaccin = Nothing
            If Not Me.EntityState = Data.EntityState.Added Then
                Me.BaremesReference.Load()
            End If
            If Me.Baremes.TypeActe = "VACC" Then
                Me.Baremes.VaccinsReference.Load()
                Vaccin = Me.Baremes.Vaccins
            End If
        End Get
    End Property

    Public ReadOnly Property DateFinValiditeVaccin() As Date
        Get
            DateFinValiditeVaccin = Nothing
            If Me.Vaccin IsNot Nothing Then
                Me.ConsultationsReference.Load()
                Return Me.Consultations.DateConsultation.AddMonths(Me.Vaccin.PeriodeValidite)
            End If
        End Get
    End Property

    Public ReadOnly Property InfoClient() As String
        Get
            Dim sb As New Text.StringBuilder("")
            sb.Append(Me.Client.NomClient).Append(" ").AppendLine(Me.Client.PrenomClient)
            sb.AppendLine(Me.Client.Adresse1)
            sb.AppendLine(Me.Client.Adresse2)
            sb.Append(Me.Client.CodePostal).AppendLine(Me.Client.Ville)
            Return sb.ToString
        End Get
    End Property

    Public ReadOnly Property monIndex() As Integer
        Get
            Me.ConsultationsReference.Load()
            Return Me.Consultations.mesLignes.IndexOf(Me) + 1
        End Get
    End Property

End Class
